package com.daigoudao.web.model;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.daigoudao.util.Constants;
import com.daigoudao.util.NumberUtil;

public class TransInfoModel extends BasePageModel {

	private static final long serialVersionUID = -5268932520453942071L;

	private int orderId;

	/**
	 * 交易流水号：yyyyMMdd+8位数字
	 */
	private String transId;

	/**
	 * 邀约信息ID
	 */
	private int inviteId;

	/**
	 * 搭车求购ID
	 */
	private int simpleId;
	/**
	 * 状态 0、待支付 1、待发货 2、确认收货 3、交易完成 4、交易关闭
	 */
	private int state;

	/**
	 * 留言信息
	 */
	private String message;

	/**
	 * 交易起始时间
	 */
	private Date startTime;

	/**
	 * 发货时间
	 */
	private Date sendTime;

	/**
	 * 支付时间
	 */
	private Date payTime;

	/**
	 * 交易完成时间，即确认收货时间
	 */
	private Date endTime;

	private double payment;

	private int userEvaluation;

	private int brokerEvaluation;

	/**
	 * 求购信息ID
	 */
	private int wantId;

	private int number;

	private int notEqualState = -1;

	private double serviceFee;

	private double platformFee;

	private double settlementAmount;

	/**
	 * 支付宝交易号
	 */
	private String tradeNo;

	/**
	 * 买宝支付宝账号：手机号或Email
	 */
	private String buyerAlipayEmail;

	/**
	 * 买家支付宝账户号
	 */
	private String buyerAlipayId;

	private AddressModel address = new AddressModel();

	/**
	 * 买家信息
	 */
	private UserModel buyer = new UserModel();

	/**
	 * 经纪人信息
	 */
	private UserModel broker = new UserModel();

	/**
	 * 物流信息
	 */
	private Logistics logistics = new Logistics();

	/**
	 * 运费
	 */
	private double logisticCharge;

	/**
	 * 交易详情
	 */
	private List<OrderDetailModel> orderDetails = new ArrayList<OrderDetailModel>();

	public int getOrderId() {
		return orderId;
	}

	public void setOrderId(int orderId) {
		this.orderId = orderId;
	}

	public String getTransId() {
		return transId;
	}

	public void setTransId(String transId) {
		this.transId = transId;
	}

	public int getInviteId() {
		return inviteId;
	}

	public void setInviteId(int inviteId) {
		this.inviteId = inviteId;
	}

	public int getWantId() {
		return wantId;
	}

	public void setWantId(int wantId) {
		this.wantId = wantId;
	}

	public AddressModel getAddress() {
		return address;
	}

	public void setAddress(AddressModel address) {
		this.address = address;
	}

	public UserModel getBuyer() {
		return buyer;
	}

	public void setBuyer(UserModel buyer) {
		this.buyer = buyer;
	}

	public UserModel getBroker() {
		return broker;
	}

	public void setBroker(UserModel broker) {
		this.broker = broker;
	}

	public Logistics getLogistics() {
		return logistics;
	}

	public void setLogistics(Logistics logistics) {
		this.logistics = logistics;
	}

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getSendTime() {
		return sendTime;
	}

	public void setSendTime(Date sendTime) {
		this.sendTime = sendTime;
	}

	public Date getPayTime() {
		return payTime;
	}

	public void setPayTime(Date payTime) {
		this.payTime = payTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	/**
	 * 商品总价，不含运费
	 * 
	 * @return
	 */
	public double getTotal() {
		double total = 0;
		for (OrderDetailModel detail : orderDetails) {
			total += detail.getSubTotal();
		}
		return BigDecimal.valueOf(total).setScale(2, BigDecimal.ROUND_HALF_UP)
				.doubleValue();
	}

	public double getPayment() {
		return BigDecimal.valueOf(payment)
				.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
	}

	public void setPayment(double payment) {
		this.payment = payment;
	}

	public int getUserEvaluation() {
		return userEvaluation;
	}

	public void setUserEvaluation(int userEvaluation) {
		this.userEvaluation = userEvaluation;
	}

	public int getBrokerEvaluation() {
		return brokerEvaluation;
	}

	public void setBrokerEvaluation(int brokerEvaluation) {
		this.brokerEvaluation = brokerEvaluation;
	}

	public List<OrderDetailModel> getOrderDetails() {
		return orderDetails;
	}

	public void setOrderDetails(List<OrderDetailModel> orderDetails) {
		this.orderDetails = orderDetails;
	}

	public int getSimpleId() {
		return simpleId;
	}

	public void setSimpleId(int simpleId) {
		this.simpleId = simpleId;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public int getNumber() {
		return number;
	}

	public void setNumber(int number) {
		this.number = number;
	}

	public int getNotEqualState() {
		return notEqualState;
	}

	public void setNotEqualState(int notEqualState) {
		this.notEqualState = notEqualState;
	}

	public double getServiceFee() {
		return BigDecimal.valueOf(serviceFee)
				.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
	}

	public void setServiceFee(double serviceFee) {
		this.serviceFee = serviceFee;
	}

	public String getTradeNo() {
		return tradeNo;
	}

	public void setTradeNo(String tradeNo) {
		this.tradeNo = tradeNo;
	}

	public String getBuyerAlipayEmail() {
		return buyerAlipayEmail;
	}

	public void setBuyerAlipayEmail(String buyerAlipayEmail) {
		this.buyerAlipayEmail = buyerAlipayEmail;
	}

	public String getBuyerAlipayId() {
		return buyerAlipayId;
	}

	public void setBuyerAlipayId(String buyerAlipayId) {
		this.buyerAlipayId = buyerAlipayId;
	}

	public double getPlatformFee() {
		return platformFee;
	}

	public void setPlatformFee(double platformFee) {
		this.platformFee = platformFee;
	}

	public double getSettlementAmount() {
		return settlementAmount;
	}

	public void setSettlementAmount(double settlementAmount) {
		this.settlementAmount = settlementAmount;
	}

	public double getLogisticCharge() {
		return NumberUtil.getBigDecimal(logisticCharge, Constants.SCALE)
				.doubleValue();
	}

	public void setLogisticCharge(double logisticCharge) {
		this.logisticCharge = logisticCharge;
	}

}
